package scalaLearning.part6

import scala.collection.mutable.ArrayBuffer

object ComparatorDemo2 {
  def main(args: Array[String]): Unit = {
    val arr = new ArrayBuffer[Student]()
    val t1 = new Student("tom",91)
    val t2 = new Student("som",100)
    val t3 = new Student("jom",80)
    arr += t1
    arr += t2
    arr += t3
    //java和scala会将字节码文件放到一块去。
    //    println(arr.sortBy(-_.score))
    println(arr.sorted)

  }
}


case class Student(name:String,score:Int) extends Ordered[Student]{
  override def compare(that: Student): Int = {
    that.score - this.score
  }
}

